package services;

import java.io.IOException;
import java.net.URLDecoder;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import models.ApiConfigModel;

public class CleanApiConfig extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		
		//Get config id
		String path = ((HttpServletRequest) request).getRequestURI();
		String id = URLDecoder.decode(path.replaceAll(request.getServletPath() + "/", ""),"UTF-8");
		
		ApiConfigModel apiConfigModel = ApiConfigModel.getInstance();
		apiConfigModel.cleanCache(id);
		
		response.getWriter().println("clean config id " + id + " done!");
	}
}
